//
//  LDJ_TopicCell.m
//  Pianke
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 dada. All rights reserved.
//

#import "LDJ_TopicCell.h"

@implementation LDJ_TopicCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}


#pragma mark - 子视图
-(void)createSubView{
    
    //类型
    self.topicType = [[UILabel alloc]init];
        self.topicType.text = @"心理.Psychology";
    self.topicType.font = [UIFont systemFontOfSize:12];
    self.topicType.textColor = [UIColor colorWithRed:0.47 green:0.47 blue:0.47 alpha:1];
    [self.contentView addSubview:self.topicType];
    [self.topicType mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150 * EACH_WIDTH, 15 * EACH_HEIGHT));
        make.left.mas_equalTo(20 * EACH_WIDTH);
        make.top.mas_equalTo(10 * EACH_HEIGHT);
        
    }];
    
    
    //标题
    self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.text = @"大众所谓的正常，不过是一种病态的平庸";
    self.titleLabel.font = [UIFont boldSystemFontOfSize:20 * EACH_HEIGHT];
    self.titleLabel.numberOfLines = 0;
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.topicType);
        make.top.mas_equalTo(self.topicType.mas_bottom).offset(15 * EACH_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 40 * EACH_WIDTH, 50 * EACH_HEIGHT));
        
    }];
    
    
    //图片
    self.topImageView = [[UIImageView alloc]init];
        self.topImageView.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.topImageView];
    
    [self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 40 * EACH_WIDTH, 140 * EACH_HEIGHT));
        make.left.equalTo(self.titleLabel);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10 * EACH_HEIGHT);
        
    }];
    
    
    
    //内容
    self.topContents = [[UILabel alloc]init];
        self.topContents.text = @"发烧39度2，给他打电话，电话里他显得很难焦急，交代很多，最后说句照顾好自己，便挂了；后来我问他，发烧为何不来";
    self.topContents.font = [UIFont systemFontOfSize:16 * EACH_HEIGHT];
    self.topContents.textColor = [UIColor colorWithRed:0.47 green:0.47 blue:0.47 alpha:1];
    self.topContents.numberOfLines = 3;
    [self.contentView addSubview:self.topContents];
    [self.topContents mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.topImageView);
        make.top.mas_equalTo(self.topImageView.mas_bottom).offset(10 * EACH_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 40 * EACH_WIDTH, 60 * EACH_HEIGHT));
        
    }];
    
    
    //心形图
    self.heartButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.heartButton  setImage:[UIImage imageNamed:@"iconfont-xinxihuan00-2.png"] forState:UIControlStateNormal];
    [self.contentView addSubview: self.heartButton];
    [self.heartButton addTarget:self action:@selector(heartButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.heartButton mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.size.mas_equalTo(CGSizeMake(15 * EACH_WIDTH, 15 * EACH_HEIGHT));
        make.top.mas_equalTo(self.topContents.mas_bottom).offset(30 * EACH_HEIGHT);
        make.right.mas_equalTo(-60);
        
        
    }];
    
    
    //赞数
    self.zanLabel = [[UILabel alloc]init];
    self.zanLabel.font = [UIFont systemFontOfSize:EACH_HEIGHT * 12];
    self.zanLabel.textColor = [UIColor colorWithRed:0.47 green:0.47 blue:0.47 alpha:1];
    self.zanLabel.text = @"311";
    [self.contentView addSubview:self.zanLabel];
    [self.zanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.size.mas_equalTo(CGSizeMake(50 * EACH_WIDTH, 15 * EACH_HEIGHT));
        make.left.mas_equalTo(self.heartButton.mas_right).offset(10);
        make.top.equalTo(self.heartButton);
        
        
    }];
    
    
}


#pragma mark - set
-(void)setTopicModel:(LDJ_HomeModel *)topicModel{

    NSString *str = [NSString stringWithFormat:@"%@•%@",topicModel.name,topicModel.enname];
    self.topicType.text = str;
    self.titleLabel.text = topicModel.title;
    self.topContents.text = topicModel.content;
    NSString *string = [NSString stringWithFormat:@"%@", topicModel.like];
    self.zanLabel.text = string;
    
    [self.topImageView sd_setImageWithURL:topicModel.coverimg placeholderImage:[UIImage imageNamed:@"u=1640821638,783268506&fm=21&gp=0.jpg"]];
    
}







/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
